import { defineConfig } from 'vuepress/config';
import { NavConfig } from './config/nav.config';
import { PluginCodeTry } from './plugins/PluginCodeTry';


export default defineConfig({
  title: 'Beisir',
  description: '深情即是死罪，又怎怕挫骨扬灰～',
  head: [
    ['link', { rel: 'icon', href: '/favicon.ico' }]
  ],
  host: '0.0.0.0',
  port: 8899,
  locales: {
    ['/']: {
      lang: 'zh-CN',
      title: '中文',
      description: '中文注释'
    },
    ['/en/']: {
      lang: 'en-US',
      title: '英文',
      description: '英文注释'
    }
  },
  theme: 'reco',
  themeConfig: {
    navbar: true,
    logo: '/favicon.ico',
    lastUpdated: '上次更新',
    nav: NavConfig
  },
  plugins: [
    PluginCodeTry,
    // 点击效果插件
    [
      'cursor-effects', {
        size: 2, // size of the particle, default: 2
        shape: 'star', // ['star' | 'circle'], // shape of the particle, default: 'star'
        zIndex: 999999999, // z-index property of the canvas, default: 999999999
	    }
    ],
    [
      'copyright',
      {
        authorName: 'beisir', // 选中的文字将无法被复制
        minLength: 30, // 如果长度超过  30 个字符
      },
    ],
    [
      '@vuepress-reco/vuepress-plugin-kan-ban-niang',
      {
        theme: ['blackCat', 'whiteCat', 'haru1', 'haru2', 'haruto', 'koharu', 'izumi', 'shizuku', 'wanko', 'miku', 'z16']
      }
    ]
  ],
  markdown: {
    lineNumbers: true,
    extendMarkdown: md => {
      md.use(function(md) {
        const fence = md.renderer.rules.fence as any;
        md.renderer.rules.fence = (...args) => {
          let rawCode = fence(...args);
          rawCode = rawCode.replace(/<span class="token comment">\/\/ try-link https:\/\/(.*)<\/span>\n/ig, '<a href="https://$1" class="try-button" target="_blank">Try</a>');
          return `${rawCode}`
        }
      })
    }
  }
});